/*
 * @Author: zhangzhanyan 
 * @Date: 2021-07-23 15:54:38 
 * @Last Modified by: zhangzhnayan
 * @Last Modified time: 2021-07-23 16:09:43
 */

import  { Component } from 'react';
import { Button, Toast } from 'antd-mobile';


class form extends Component {
    state={
        aa:"sss",
        username:"",
        pwd:''
    }
    change=(e:any)=>{
        if(e.target.type==="text"){
            this.setState({username:e.target.value})
        }else if(e.target.type==="password"){
            this.setState({pwd:e.target.value})
        }
    }
    btn=()=>{
        let {username,pwd} =this.state
        console.log(username,pwd)
        if(username.trim()===''||pwd.trim()===''){
            this.failToast()
        }else{
            //axios 发送数据
        }
    }
     failToast=()=> {
        Toast.fail('请正确输入账号密码', 2);
      }
      componentDidMount() {
        Toast.loading('Loading...', 30, () => {
          console.log('Load complete !!!');
        });
    
        setTimeout(() => {
          Toast.hide();
        }, 2000);
      }
    render() {
        let {username,pwd} = this.state
        return (
            <div className="Register-form">
                 <h1>注册</h1>
                 <h2>经纪人不会看到您的手机号</h2>
                 <div>
                     <input type="text" placeholder="请输入手机号" value={username} onChange={(e)=>{this.change(e)}}/>
                 </div>
                 <div>
                     <input type="password" placeholder="请输入密码" value={pwd}  onChange={(e)=>{this.change(e)}}/>
                 </div>
                 <Button onClick={()=>{this.btn()}} className="btn" type="primary">注册</Button>
                 <p>注册/登录即代表同意<a href="https://m.lianjia.com/user/privacyprotocol">链家隐私政策</a>及<a href="https://m.lianjia.com/user/protocol">链家用户协议</a></p>
            </div>
        );
    }
}

export default form;